#include <it/io.h>
#include <it/mat.h>

/*

TP RAR-R

emitter file

*/

int main()
{
  size_t i;

  /* Set simulation parameters */
  const char * filename_out = "signal.wav";

  int depth                 = 16; 
  int srate                 = 44100;
  int freq                  = 440;
  double ampl               = 3000;
  int sample_period         = srate / freq;
  int nb_samples;
  mat m;

  nb_samples = 5000;
  vec v = vec_new( nb_samples );

  /* Create carrier wave  */
  for( i = 0 ; i < nb_samples ; i++ )
    v[ i ] = ampl * sin( 2 * M_PI * i / sample_period );

  /* Write the stereo matrix corresponding to the mono signal */
  m = mat_new( 2, vec_length( v ) );
  vec_copy( m[ 0 ], v );
  vec_copy( m[ 1 ], v );

  mat_wav_write( filename_out, m, srate, depth );

  mat_delete(m);
  return 0;
}
